package cn.net.wanji.job;

import cn.net.wanji.entity.Gantry;
import cn.net.wanji.mapper.MonitorMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j(topic = "初始化门架信息配置文件【ServiceConfigJob】")
@EnableScheduling
@Configuration
public class RefreshGantryDataJob {

    @Autowired
    private MonitorMapper monitorMapper;
    public static Map<String, String> gantryInfoMap = new HashMap<>();
    public static Map<String, String> gantryFlagInfoMap = new HashMap<>();

    @PostConstruct
    public void selectData() {
        List<Gantry> allGantry = monitorMapper.getAllGantry();
        for (Gantry gantry : allGantry) {
            if ("1".equals(gantry.getFlag())) {
                gantryFlagInfoMap.put("1", gantry.getId());
            } else if ("2".equals(gantry.getFlag())) {
                gantryFlagInfoMap.put("2", gantry.getId());
            }
            gantryInfoMap.put(gantry.getId(), gantry.getBelong());
        }
    }


}
